package com.modernyuanshiren.sample;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import com.modernyuanshiren.AbstractGame;
import com.modernyuanshiren.Element;
import com.modernyuanshiren.IElement;

/**
 * GameGoal:
 * ●●●＿○○○⇒○○○＿●●●
 *
 */
public class Game extends AbstractGame<SampleStatus, SampleSingleAction> {
	private final String LEFT_NAME;
	private final String RIGHT_NAME;
	private static final String EMPTY_NAME = "空格";
	private static Game game;

	public Game() {
		this(SampleStatus.class, "黑", "白");
	}

	public Game(String leftName, String rightName) {
		this(SampleStatus.class, leftName, rightName);
	}

	private Game(Class<SampleStatus> clazz, String leftName, String rightName) {
		super(clazz);
		LEFT_NAME = leftName;
		RIGHT_NAME = rightName;
		game = this;
	}

	public static Game getGameContext() {
		return game;
	}

	public String getLeftName() {
		return LEFT_NAME;
	}

	public String getRightName() {
		return RIGHT_NAME;
	}

	public String getEmptyName() {
		return EMPTY_NAME;
	}

	@Override
	protected List<IElement> getInitElements() {
		return IntStream.rangeClosed(0, 6).boxed().map(i -> {
			if (i < 3) {
				return new Element(LEFT_NAME, i);
			}
			if (i > 3) {
				return new Element(RIGHT_NAME, i);
			}
			return new Element(EMPTY_NAME, 3);
		}).collect(Collectors.toList());
	}

	public static void main(String[] args) {
		Game game = new Game();
		game.start();
	}

}
